
import 'package:flutter/cupertino.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBNetWorkModule/YBNetConfig.dart';

class YBBaseResultData{
  Map<String, dynamic> response; //所有返回值
  dynamic data; //请求回来的data，可能是list也可能是map
  String code; //服务器的状态码
  String msg; //服务器给的提示信息
  //true 请求成功 false 请求失败
  bool reuslt = true; //客户端是否请求成功false:HTTP错误
  String url = "";

  YBBaseResultData(this.msg,this.reuslt,{this.url = ""});

  YBBaseResultData.response(this.response,{this.url = ""}){
    this.code = this.response["success"];
    this.msg = this.response["msg"];
    this.data = this.response["data"];
  }

  bool isFail() {
    bool success = reuslt && code == '0';
    if (!success) {

    }
    return !success;
  }

  bool isSuccess() {
    bool success = reuslt && code == "0";
    if (!success) {

    }
    return success;
  }

  bool toast() {
    if (isFail()) {
      return true;
    } else{
      return false;
    }
  }

  mDebugPrint(String log){
    if (YBNetConfig.DEBUG) {
       debugPrint(log);
    }
  }

}